#include "my_sensor.h"
#include "i2c.h"

uint8_t ReadID()
{
    uint8_t whoami;
    if (HAL_I2C_Mem_Read(&hi2c1, LIS3DSH_READ_ADDR, LIS3DSH_WHO_AM_I_ADDR, 1, (uint8_t *)&whoami, 1, 0xff) != HAL_OK)
    {
        printf("HAL IIC read WHO_AM_I ERROR\r\n");
    }
    return whoami;
}

uint8_t ReadTemperature()
{
    uint8_t temp;
    HAL_I2C_Mem_Read(&hi2c1, LIS3DSH_READ_ADDR, LIS3DSH_OUT_T_ADDR, 1, (uint8_t *)&temp, 1, 0xff);
    // printf("read Temp is %d\r\n",temp);
    return temp;
}

uint8_t ReadStatus()
{
    uint8_t status;
    HAL_I2C_Mem_Read(&hi2c1, LIS3DSH_READ_ADDR, LIS3DSH_STATUS_ADDR, 1, (uint8_t *)&status, 1, 0xff);
    return status;
}
void ReadXYZ(uint8_t *pdata)
{
      HAL_I2C_Mem_Read(&hi2c1, LIS3DSH_READ_ADDR, LIS3DSH_OUT_X_L_ADDR, 1, pdata, 6, 0xff);
}